Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
How add [event.target.name] in array selector - next.js app

I have two onChange handlers in my next app, and i would like split this two onChange handlers split in to one. Problem is i really dont know how make right syntax in array selector

// Working solution with two handlers

  const ticketPriceInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].price = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

  const ticketPiecesInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].pieces = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

I try it make one just handler like down on example but i getting always errors..

  const oneHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

   items[index].wave[index2].event.taget.name = e.target.value;   // Here is problem 

       setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

or i try it

    const nameOfField = e.target.name 

    items[index].wave[index2].nameOfField = e.target.value;   

// here i getting new in object field instead of field name from const nameOfField

What is a right syntax for this ? Thanks

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda